package com.ruoyi.project.business.domain.rules.month;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.business.domain.entity.Emp;
import com.ruoyi.project.business.domain.model.JudgeResult;
import com.ruoyi.project.business.domain.model.Solution;
import com.ruoyi.project.business.domain.rules.Rule;
import lombok.Data;

import java.time.DayOfWeek;
import java.util.Arrays;

/**
 * 周一不上班的校验
 * 智能排班用。
 */
@Data
public class NotMonday extends Rule {
    @Override
    public JudgeResult judge(Solution solution, Emp emp) {
        boolean ifDay = DateUtils.ifDay(shift.getAimDate(), DayOfWeek.MONDAY);
//        boolean ifDay = DateUtils.ifMonday(shift.getAimDate());
        if(ifDay) {
            //
            if (getBreakIfReject()) {
                return stopTask();
            } else {
                return acceptAndReturn();
            }
        } else {
            return accept();
        }
    }

    @Override
    public void setConflicts() {
        setType(Rule.RULE_TYPE_USER);
        this.conflicts = Arrays.asList(MustMonday.class);
    }
}
